class MyCircularQueue {
    public int[] elem;
    int fron;//指向队头
    int rear;//指向队尾

    public MyCircularQueue(int k) {
        this.elem = new int[k];
    }

    public boolean enQueue(int value) {
        //判空
        //如果满了 需要扩容的话 要重新确定fron 和 rear
        if(isFull()){
            return false;
        }else {
            elem[rear] = value;
            rear = (rear + 1)%elem.length;
            return true;
        }


    }

    public boolean deQueue() {
        //判空
        if(isEmpty()){
            return false;
        }else {
            fron=(fron+1)%elem.length;
            return true;
        }

    }

    public int Front() {
        //判空
        if(isEmpty()){
            return -1;
        }
        return elem[fron];

    }

    public int Rear() {

        int index = (rear==0)?(elem.length-1):(rear-1);
        return elem[index];


    }

    public boolean isEmpty() {
        return rear == fron;

    }

    public boolean isFull() {
       return (rear+1)% elem.length == fron;

    }
}